package logic

import (
	"context"
	"test-demo/model"

	"test-demo/user_srv/internal/svc"
	"test-demo/user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type LoginLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic {
	return &LoginLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LoginLogic) Login(in *user.LoginRequest) (*user.Response, error) {
	// todo: add your logic here and delete this line
	res := model.Login(in.Username, in.Password)
	if res == "0" {
		return &user.Response{
			Status: "0",
		}, nil
	}
	return &user.Response{
		Status: res,
	}, nil
}
